﻿
namespace Mbs.CastleContainer.Facilities
{
    
    /// <remarks>采用装设模式和单例模式来实现</remarks>
    public class StopConcern : Castle.MicroKernel.LifecycleConcerns.ILifecycleConcern
    {
        public static readonly StopConcern Instance = new StopConcern(Castle.Facilities.Startable.StopConcern.Instance);

        private Castle.MicroKernel.LifecycleConcerns.ILifecycleConcern InnerConcern;

        protected StopConcern(Castle.MicroKernel.LifecycleConcerns.ILifecycleConcern concern)
        {
            InnerConcern = concern;
        }

        public void Apply(Castle.Core.ComponentModel model, object component)
        {
            if (component is IStartable)
                (component as IStartable).Stop();
            else
                InnerConcern.Apply(model, component);
        }
    }
}